const {defineConfig} = require('@vue/cli-service')
module.exports = defineConfig({
    transpileDependencies: true,
    // 解决控制台 __VUE_PROD_HYDRATION_MISMATCH_DETAILS__ 警告问题
    chainWebpack: (config) => {
        config.plugin('define').tap((definitions) => {
            Object.assign(definitions[0], {
                __VUE_OPTIONS_API__: 'true',
                __VUE_PROD_DEVTOOLS__: 'false',
                __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false'
            })
            return definitions
        })
    },
    // 配置代理
    devServer: {
        allowedHosts: ['all'],
        historyApiFallback: true,
        client: {
            // 当出现编译错误或警告时，在浏览器中是否显示全屏覆盖
            overlay: {
                runtimeErrors: false,
            }
        },
        proxy: {
            // detail: https://cli.vuejs.org/config/#devserver-proxy
            [process.env.VUE_APP_BASE_API]: {
                target: 'http://localhost:8080',
                changeOrigin: true,
                ws: true,
                secure: true,
                pathRewrite: {
                    ['^' + process.env.VUE_APP_BASE_API]: ''
                }
            },
            [process.env.VUE_APP_ATTACH_API]: {
                target: 'http://localhost:8080',
                changeOrigin: true,
                pathRewrite: {
                    ['^' + process.env.VUE_APP_ATTACH_API]: ''
                }
            },
        }
    }
})
